
#include "activationsystemdbus.h"
#include <QDebug>
#include <QMap>
#include <QDBusReply>


//dbus配置函数
SystemDispatcher::SystemDispatcher(QObject *parent)
//    QObject(parent)
{
    systemiface = new QDBusInterface("org.freedesktop.activation",
                               "/org/freedesktop/activation",
                               "org.freedesktop.activation.interface",
                               QDBusConnection::systemBus());
}

//析构函数
SystemDispatcher::~SystemDispatcher() {
    this->exit_qt();
    if (systemiface != NULL) {
        delete systemiface;
        systemiface = NULL;
    }
}

//退出
void SystemDispatcher::exit_qt() {
    systemiface->call("exit");
}

//从后台获取序列号
QString SystemDispatcher::get_serial_number_qt() {
    QDBusReply<QStringList> reply = systemiface->call("serial_number");
    qDebug() << "seiral->" << reply.value();
    return reply.value();
}



//gint activation_dbus_serial_number(ActivationDbus * dbus, DBusGMethodInvocation * ret_value)


//gint activation_dbus_register_number(ActivationDbus * dbus, DBusGMethodInvocation * ret_value)


//gint activation_dbus_qrcode(ActivationDbus * dbus, DBusGMethodInvocation * ret_value)


//gint activation_dbus_activate(ActivationDbus * dbus, gchar * code, DBusGMethodInvocation * ret_value)

//gint activation_dbus_work(ActivationDbus * dbus, gchar * path, DBusGMethodInvocation * ret_value)



QStringList SystemDispatcher::get_register_number_qt() {
    QStringList tmp;
    return tmp;
//    QDBusReply<QStringList> reply = systemiface->call("get_register_number");
//    return reply.value();
}

QStringList SystemDispatcher::get_qrcode_qt() {
    QStringList tmp;
    return tmp;
//    QDBusReply<QStringList> reply = systemiface->call("get_qrcode");
//    return reply.value();
}

QString SystemDispatcher::activation_activate_system_qt(QString acti) {
    QStringList tmp;
    return tmp;
//    QDBusReply<QString> reply = systemiface->call("activation_activate_system", acti);
//    return reply.value();
}
